package com.liuugoqing.creator.factory.method;

/**
 * 咖啡店，直接从具体工厂获取具体产品
 * @Author : liugq
 * @Date : 2022/7/1 0:03
 * @See : 参考类
 * @Since： JDK1.8
 * @Version : 1.0
 */
public class CoffeeStore {
    private CoffeeFactory factory;

    /**
     * 将构造方法种添加具体工厂
     * @param factory
     */
    public CoffeeStore(CoffeeFactory factory){
        this.factory = factory;
    }

    /**
     * 点咖啡
     * @return
     */
    public Coffee orderCoffee() {
        Coffee coffee = factory.createCoffee();
        coffee.addMilk();
        coffee.addSugar();
        System.out.println(coffee.getName());
        return coffee;
    }
}
